package com.keray.web.push;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Hello world!
 * mvn package -pl com.vip.langrun:acl -am --also-make -Dmaven.test.skip=true -DskipTests=true
 */
@SpringBootApplication
@EnableConfigurationProperties
@ConfigurationPropertiesScan
@RestController
@EnableScheduling
public class WebPushStart {


    public static void main(String[] args) {
        System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", "500");
        SpringApplication.run(WebPushStart.class, args);
    }

    @EventListener
    public void started(ApplicationEvent applicationEvent) {
        if (applicationEvent instanceof ApplicationStartedEvent) {
            System.out.println("addp-app-start-success");
        } else if (applicationEvent instanceof ApplicationFailedEvent) {
            System.out.println("addp-app-start-fail");
        } else if (applicationEvent instanceof ContextClosedEvent) {
            System.out.println("addp-app-close");
        }
    }

    @GetMapping("/check-health")
    public Object checkHealth() {
        return "OK";
    }
}
